package com.lsec.springbootinit.event.user;

import lombok.Data;
import org.springframework.context.ApplicationEvent;

import java.time.Clock;

/**
 * 用户注册事件类
 *
 * @author Cherry
 * @date 2023-06-21 14:02
 */


public class UserRegisterEvent extends ApplicationEvent {

    private String name;


    /**
     * Create a new {@code ApplicationEvent} with its {@link #getTimestamp() timestamp}
     * set to {@link System#currentTimeMillis()}.
     *
     * @param source the object on which the event initially occurred or with
     *               which the event is associated (never {@code null})
     */
    public UserRegisterEvent(Object source) {
        super(source);
        this.name = (String) source;
    }

    /**
     * Create a new {@code ApplicationEvent} with its {@link #getTimestamp() timestamp}
     * set to the value returned by {@link Clock#millis()} in the provided {@link Clock}.
     * <p>This constructor is typically used in testing scenarios.
     *
     * @param source the object on which the event initially occurred or with
     *               which the event is associated (never {@code null})
     * @param clock  a clock which will provide the timestamp
     * @since 5.3.8
     */
    public UserRegisterEvent(Object source, Clock clock) {
        super(source, clock);
    }

    public String getName() {
        return name;
    }
}
